package com.tsll.controller;


import com.tsll.annotation.MyLog;
import com.tsll.entity.PurchaseBookInfo;
import com.tsll.service.PurchaseBookInfoService;
import com.tsll.vo.PurchaseBooksInfoVo;
import com.tsll.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 * @author: Tian
 * @version: 1.0
 * @since: 1.0
 * @date: 2024/3/25/9:09
 */
@RestController
@RequestMapping("/purchaseBookInfo")
public class PurchaseBookInfoController {
    @Autowired
    PurchaseBookInfoService purchaseBookInfoServiceImpl;


    /**
     * 根据采购申请编号查询采购详情
     *
     * @param purchaseinfoId
     * @return
     */
    @MyLog(businessName = "根据采购申请编号查询采购详情")
    @RequestMapping("/selectByPurchaseinfoId/{purchaseinfoId}")
    public Result selectByPurchaseinfoId(@PathVariable Integer purchaseinfoId) {
        List<PurchaseBookInfo> purchaseBookInfos = purchaseBookInfoServiceImpl.selectByPurchaseinfoId(purchaseinfoId);
        return new Result(200, "根据采购申请编号查询采购详情查询成功", purchaseBookInfos);
    }

    /**
     *
     * @param id
     * @return
     */
    @MyLog(businessName = "根据id删除采购详情")
    @RequestMapping("/deleteById/{id}")
    public Result deleteById(@PathVariable Integer id) {
        purchaseBookInfoServiceImpl.deleteById(id);
        return new Result(200, "删除成功", null);
    }

    /**
     * 根据id修改图书信息
     *
     * @param purchaseBookInfo
     * @return
     */
    @MyLog(businessName = "根据id修改图书信息")
    @RequestMapping("/updateById")
    public Result updateById(@RequestBody PurchaseBookInfo purchaseBookInfo) {
        purchaseBookInfoServiceImpl.updateById(purchaseBookInfo);
        return new Result(200, "根据id修改图书信息", null);
    }

    @MyLog(businessName = "添加图书")
    @RequestMapping("/addBookInfo")
    public Result insetBookInfo(@RequestBody PurchaseBookInfo purchaseBookInfo) {
        purchaseBookInfoServiceImpl.insetBookInfo(purchaseBookInfo);
        return new Result(200, "添加图书成功", null);
    }

    //查询已入库
    @RequestMapping("/check/{current}/{pageSize}")
    public Result check(@PathVariable Integer current, @PathVariable Integer pageSize, @RequestBody PurchaseBooksInfoVo purchaseBooksInfoVo) {
        return purchaseBookInfoServiceImpl.check(current, pageSize, purchaseBooksInfoVo);
    }

    //查询未入库
    @RequestMapping("/Ware")
    public List<PurchaseBookInfo> Ware(@RequestBody PurchaseBooksInfoVo purchaseBooksInfoVo) {
        return purchaseBookInfoServiceImpl.Ware(purchaseBooksInfoVo);
    }

    //入库确定
    @RequestMapping("/updatestatus")
    public  Result updatestatus(@RequestBody List<PurchaseBooksInfoVo> bookList) {
        return purchaseBookInfoServiceImpl.updatestatus(bookList);
    }


}
